package com.JFapp.controller;


import com.JFapp.domain.entity.ResponseResult;
import com.JFapp.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article")
@Api("文章管理")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @ApiOperation("查询热门文章")
    @GetMapping("/hotArticleList")
    public ResponseResult hotArticleList(){

        ResponseResult result= articleService.hotArticleList();
        return result;
    }

    @ApiOperation("查询文章")
    @GetMapping("/articleList")
    public ResponseResult articleList( Integer pageNum, Integer pageSize, Long categoryId){
        ResponseResult result= articleService.articleList(pageNum,pageSize,categoryId);
        return result;
    }

    @ApiOperation("查询文章（详细）")
    @GetMapping("/{articleId}")
    public  ResponseResult getArticleDetail(@PathVariable("articleId") Long id){
        ResponseResult result = articleService.getArticleDetail(id);
        return result;
    }

    @ApiOperation("更新浏览量")
    @PutMapping("updateViewCount/{id}")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){
        return articleService.updateViewCount(id);
    }

}
